<template>
  <el-form :model="userobj" label-width="auto" style="max-width: 600px">
    <el-form-item label="电话号码">
      <el-input v-model="userobj.phonenumber" />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="userobj.password" />
    </el-form-item>
    <el-button type="primary" @click="add">提交</el-button>
  </el-form>
</template>

<script setup>
  import {ref} from "vue"
  import axios from "axios"

  let userobj = ref({
    phonenumber: "",
    password: ""
  })

  const add=()=>{
    // console.log(userobj.value)
    axios.post("http://127.0.0.1:8000/login/user/", userobj.value)
    .then(res=>{
      console.log(res)
      alert("添加成功")
    })
    .catch(error=>{
      alert(error.response.data.phonenumber.msg)
      console.log(error)
    })
  }

</script>